@extends('admin.base')
	@section('content')
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            首页轮播图表
            <small>mall genres of simple table</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="{{url('admin')}}"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">首页轮播图信息</a></li>
            <li class="active">列表</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
			<div class="row">
				<div class="col-md-12">
					<div class="box">
						<div class="box-header with-border">
							<h3 class="box-title"><i class="fa fa-th"></i> 首页轮播图管理 </h3>
							<br><br>
							<button class="btn btn-primary" onclick="loadAdd()">添加轮播图</button>
							<div class="box-tools">
								<form action="{{url('admin/slide')}}" method="get">
									<div class="input-group" style="width: 150px;">
									  <input type="text" name="name" class="form-control input-sm pull-right" placeholder="查询名称"/>
									  <div class="input-group-btn">
										<button class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
									  </div>
									</div>
								</form>
							</div>
						</div><!-- /.box-header -->
						<div class="box-body">
							<table class="table table-bordered">
								<tr>
								  <th>类别号</th>							  
								  <th>类别名称</th>	
								  <th>是否首页轮播</th>	
								  <th>图片</th>		
								  <th>操作</th>
								</tr>
								@foreach($list as $slide)
								<tr>
								  <td>{{$slide->id}}</td>
								  <td>{{$slide->name}}</td>
								  <td>@if($slide->sorder == 1) 开启 @else 关闭 @endif</td>
								  <td width="5px"><a href='{{url("admin/slide/$slide->name")}}' class="btn btn-xs btn-danger">浏览</a> </td>
								  <td><button onclick="doDel({{$slide->id}});" class="btn btn-xs btn-danger">删除</button> 
								  <a href='{{url("admin/slide/$slide->id/edit")}}' class="btn btn-xs btn-primary">编辑</a>
								  <a href='{{url("admin/slide/$slide->name/edit")}}' class="btn btn-xs btn-primary">开关</a>
								  </td>
								</tr>
								@endforeach
							</table>
							<form id="mydeleteform" method="post">
								<input type="hidden" name="_method" value="delete">
								<input type="hidden" name="_token" value="{{ csrf_token() }}">
							</form>
						</div><!-- /.box-body -->
						<div class="box-footer clearfix">
						  {!! $list->appends($params)->render() !!}
						</div>
					</div><!-- /.box -->
				</div><!-- /.col -->
			</div><!-- /.row -->
		</section><!-- /.content -->
	@endsection
	
	@section("myscript")
	
	<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">New message</h4>
          </div>
          <div class="modal-body">
           <!-- 此处填充 -->
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="saveType()" class="btn btn-primary">添加</button>
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript">
        function doDel(id){
            Modal.confirm({msg:'是否删除此类别？'}).on(function (e){
                if(e){
                    var form = document.getElementById("mydeleteform");
                    form.action = "{{URL('/admin/slide')}}/"+id;
                    form.submit(); 
                }
            });
        }
        
        //加载添加表单
        function loadAdd(){
            $("#exampleModalLabel").html("添加商品类别");
            $("#exampleModal").modal("show");
            
            $.ajax({
                url:"{{URL('admin/slide/create')}}",
                type:"get",
                dataType:"html",
                async:true,
                success:function(data){
                  $("#exampleModal .modal-body").html(data);   
                },
             });
            
        }
        
        //保存类别信息
        function saveType(){
            $("#myaddform").submit();
            /*
            $.ajax({
                url:"{{url('admin/genre')}}",
                type:"post",
                dataType:"html",
                data:$("#myaddform").serialize() ,
                async:true,
                success:function(data){
                    $('#exampleModal').modal('hide');
                    Modal.alert({msg:data,title: ' 信息提示',btnok: '确定',btncl:'取消'});
                    $("div.content-wrapper").html(data);
                },
             });
            */
        }
            
    </script>
	@endsection